<!doctype html>
<html>
{include file="head.html"}

<body>
 <div class="fullscreen">

	<div class="topfixed">
      <div class="t_left"><a href="/index.php" class="goBack"><i class="back"></i></a></div>
      <div class="t_main">论坛</div>
   	<div class="t_right"><a href="/index.php?m=forum&a=add" class="link">发帖</a></div>	
    </div> 
    <div class="paddingheight"></div>
    <div class="comblock" style="position:relative;">
 	<div class="tab-select ">
    		<div class="item" id="tab-category-box" to="category-box"><span class="t">全部分类</span> <i class="t3down "></i><b></b></div>
            
            <div class="item" id="tab-order-box" to="order-box"><span class="t">智能排序</span> <i class="t3down"></i><b></b></div>
            	
    		 
    		<div class="item" id="tab-choice-box" to="choice-box"><span class="t">筛选</span> <i class="t3down"></i></div>
    </div>
	
    <div id="category-box" name="category" class="tab-select-box">
    	<div class="box1">
        	<div class="pd">
        	{foreach item=c from=$catlist}
        	<div   to="c{$c.catid}" class="box1item   {if $c.catid eq get('catid') or $cat.pid eq $c.catid}active{/if}">{$c.cname}</div>
            {/foreach} 
            </div>
        </div>
        <div class="box2">
         	<div class="pd">
        	{foreach item=c from=$catlist}
            <div   v="{$c.catid}" class="box2item   c{$c.catid} {if $c.catid eq $c.catid}show{/if} ">{$c.cname}</div>
            {foreach item=cc from=$c.child}
        	<div   v="{$cc.catid}" class="box2item   c{$c.catid} {if $cat.catid eq $c.catid}show{/if} ">{$cc.cname}</div>
            {/foreach}
            {/foreach} 
            </div> 
        </div>
         
    </div>
    
    
    
    <div id="order-box" name="order" class="order-box tab-select-box">
    	<a class="item" v="">智能排序</a>
         <a class="item" v="new">最新</a> 
         <a class="item" v="hot">最热</a>                 
    </div>
    
    <div id="choice-box" name="filter" class="choice-box tab-select-box">
    	<a class="item" v="">全部</a>
    	<a class="item" v="isrecommend">推荐</a>
        <a class="item" v="isnew">最新</a>
        <a class="item" v="ishot">热门</a>
    </div>

  
 </div>
    <ul class="data-list" id="data-list">
{foreach item=c from=$list}
        <li {if $c.imgurl} class="hasimg"{/if}>
            <a class="aurl" href="{R("/index.php?m=show&id=$c.id")}">
               {if $c.imgurl} <img src="{$c.imgurl|images_site}.100x100.jpg"/>{/if}
                <dl>
                    <dt>{$c.title}</dt>
                    <dd class="time">{$c.dateline|timeago}</dd>
                    <dd class="content">{$c.description}</dd>
                    <dd class="source">作者：{$c.nickname}</dd> 
                </dl>
            </a>
        </li>
    {/foreach}
</ul> 
<div class="pullup" id="loadmore">加载更多</div>
{include file="footer.html"}
</div>
<script id="data-list-tpl" type="text/html">
	<%for(var i=0;i<list.length;i++){%>
	 	<li <%if(list[i].imgurl){%> class="hasimg"<%}%>>
            <a class="aurl" href="/index.php?m=show&id=<%=list[i].id%>">
              <%if(list[i].imgurl){%> <img src="<%=images_site(list[i].imgurl)%>.100x100.jpg"/><%}%>
                <dl>
                    <dt><%=list[i].title%></dt>
                    <dd class="time"><%=timeago(list[i].dateline)%></dd>
                    <dd class="content"><%=list[i].description%></dd>
                    <dd class="source">作者：<%=list[i].nickname%></dd> 
                </dl>
            </a>
        </li>
	<%}%>
</script>
<script src="/plugin/jquery/template-native.js"></script>
 <script src="/plugin/skyweb/listload.js"></script>
  <script>
	  var orderby='',catid=0,filter='',cityid=0,first=false;; 
	  var per_page={$per_page};
	 function loadData(){
		if(per_page==0 && !first){		 
			return false; 
		 }
		$.get('/index.php?m=forum&ajax=1&catid='+catid+"&orderby="+orderby+"&filter="+filter+"&per_page="+per_page,function(data){
			per_page=data.data.per_page;
			if(per_page==0){
				//skyToast('没有数据了');
				$("#loadmore").hide();
			}else{
				$("#loadmore").show();
			}
			var html=template("data-list-tpl",data.data);
			if(first){
				first=false;
				$("#data-list").html(html);
				
			}else{
				$("#data-list").append(html);
			}
		},"json");
	}
	
	listload.loadid="#loadmore";
	listload.showload(function(){
			loadData();
	 });

    	$(function(){
			$(document).on("click",".box1item",function(e){
				e.preventDefault();
				
				$(".box1item").removeClass("active");
				$(this).addClass("active");
				$(".box2item").hide();
				$(".box2item."+$(this).attr("to")).css({display:"block"});
			});
			
			$(document).on("click",".box2item",function(){
				catid=$(this).attr("v");
				per_page=0;
				first=true;
				$(".box2item").removeClass("active");
				$(this).addClass("active");
				$("#tab-category-box .t").text($(this).text());
				loadData();
				$("#category-box").hide();
			});
			$(document).on("click",".tab-select .item",function(){
				var to=$(this).attr("to");		 
				$("#"+to).toggle().siblings(".tab-select-box").hide();
			});			
			$(document).on("click",".tab-select-box .item",function(){
				$(".tab-select-box").hide();
				var para=$(this).parents(".tab-select-box").attr("name");
				var v=$(this).attr("v");
				per_page=0;
				first=1;
				switch(para){
					case "category":
							catid=v;
						break;
					case "order":
							orderby=v;
						break;
					case "filter":
							filter=v;
						break;
				
				}
				$("#tab-"+$(this).parents(".tab-select-box").attr("id")+" .t").text($(this).text());

				loadData();
			});
		});
    </script>
</body>
</html>
